import java.io.*;
import java.util.*;

/**
 * A wrapper for HashMap with faster I/O.
 * 
 * @author Fredrik, Viktor
 */

public class FastHashMap extends HashMap<String, Integer> implements
		Externalizable {

	@Override
	public void readExternal(ObjectInput in) throws IOException,
			ClassNotFoundException {
		try {
			String key = "";
			while ((key = in.readUTF()) != null)
				this.put(key, in.readInt());
		} catch (EOFException e) {
			return;
		}

	}

	@Override
	public void writeExternal(ObjectOutput out) throws IOException {
		for (Iterator<String> iter = this.keySet().iterator(); iter.hasNext();) {
			String key = iter.next();
			out.writeUTF(key);
			out.writeInt(this.get(key));
		}
	}

}
